package com.zucc.eye.mqtt;

import lombok.Data;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Component;

@Component
@Configuration
@PropertySource("classpath:application.yml")
//指明配置文件位置  会自动去resouces下找到此文件
//@ConfigurationProperties(prefix = "mqtt")
//添加一个 配置，万一要改 只要在这里改就好了，集中在一起，比较方便
@Data
public class MqttConfig {

     public  static  String[] topics;
    public  static int[] qos = {1, 1, 1,
            1, 1,1,
            1,1};

    @Value("${mqtt.host}")
    public static   String MQTT_HOST ;
    @Value("${mqtt.client_id}")
    public static  String MQTT_CLIENT_ID ;
    @Value("${mqtt.username}")
    public static  String MQTT_USERNAME ;
    @Value("${mqtt.password}")
    public static  String MQTT_PASSWORD ;

    //要写在 set
    @Value("${mqtt.host}")
    public void setMQTT_HOST(String mqttHost) {
        MQTT_HOST = mqttHost;
    }
    @Value("${mqtt.client_id}")
    public void setMQTT_CLIENT_ID(String mqtt_client_id) {
        MQTT_CLIENT_ID = mqtt_client_id;
    }
    @Value("${mqtt.username}")
    public void setMQTT_USERNAME(String mqtt_username) {
        MQTT_USERNAME = mqtt_username;
    }
    @Value("${mqtt.password}")
    public void setMQTT_PASSWORD(String mqtt_password) {
        MQTT_PASSWORD = mqtt_password;
    }

    //@Bean
    public MqttConfig() {

    }

    public static void main(String[] args) {
    }
}
